package com.itheima.sh.esdemo.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.sh.esdemo.mapper.SearchMapper;
import com.itheima.sh.esdemo.pojo.Sku;
import com.itheima.sh.esdemo.service.SearchService;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
public class SearchServiceImpl extends ServiceImpl<SearchMapper, Sku> implements SearchService {

    @Override
    public Map findSkuPage(Integer currentPage, Integer pageSize) {
        Page<Sku> page=page(new Page<Sku>(currentPage,pageSize));
        List<Sku> records = page.getRecords();
        long total = page.getTotal();
        Map<String, Object> map = new HashMap<>();
        map.put("total", total);
        map.put("records", records);
        return map;
    }
}
